#include "fxcc/core/graph/opengl3/Program.h"

using namespace fxcc::graph::opengl3;


bool fxcc::graph::opengl3::Program::Init2()
{
	return true;
}

void Program::Use() const
{
	glUseProgram(m_Id);
}

void Program::Create()
{
	m_Id = glCreateProgram();
}

void Program::Release()
{
	glDeleteProgram(this->m_Id);
}

void Program::Link()
{
	glLinkProgram(m_Id);
};


void Program::UnUse()
{
	glUseProgram(0);
}

void fxcc::graph::opengl3::Program::Delete() const
{
	glDeleteProgram(m_Id);
}

void fxcc::graph::opengl3::Program::Bind(const std::string &name, unsigned int binding)
{
	glUniformBlockBinding(m_Id, GetUniformBlockIndex(name), binding);
}

unsigned int fxcc::graph::opengl3::Program::GetUniformBlockIndex(const std::string &name)
{
	return glGetUniformBlockIndex(m_Id, name.c_str());
}

fxcc::graph::opengl3::Program::~Program()
{
	Delete();
}
